package org.example.sdpback.config;

import lombok.RequiredArgsConstructor;
import org.example.sdpback.interceptors.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @className: WebConfig
 * @author: zxy
 * @date: 2024/11/3 15:59
 * @Version: 1.0
 * @description:
 **/
@Configuration
@RequiredArgsConstructor
public class WebConfig implements WebMvcConfigurer {

    private final LoginInterceptor loginInterceptor;

    // spring mvc 拦截器注册添加
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor).excludePathPatterns(
                "/user/login",
                "/user/register",
                "/openapi-resources/**",
                "/webjars/**",
                "/favicon.ico",
                "/v3/**",
                "/doc.html/**"
        );
    }
}
